// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
import { ipcRenderer, contextBridge } from 'electron'
import { CreateChatProps, UpdatedStreamData, OnUpdatedCallBack } from './types'

contextBridge.exposeInMainWorld('electronAPI', {
    // 向主进程发送数据
    startChat: (data: CreateChatProps) => ipcRenderer.send('start-chat', data),
    // 监听主进程事件
    onUpdateMessage: (callback: OnUpdatedCallBack) => ipcRenderer.on('update-message', (_event, data: UpdatedStreamData) => callback(data))
})